import React, {Component} from 'react';

class Index extends Component {
    state={
        isCard:true,
        name:"张三"
    }
    render() {
        return (
            <div>
                {
                    this.state.isCard===true?<Child name={this.state.name}></Child>:""
                }
                <button onClick={()=>{
                    this.setState({
                        isCard:false
                    })
                }}>改变</button>
            </div>
        );
    }

}
class Child extends Component{
    render() {
        return(
            <div>
                {this.props.name}
            </div>
        )
    }
    //销毁组件之后的操作 必须在子组件使用
    componentWillUnmount() {
        console.log("componentWillUnmount")
    }
}
export default Index;
